﻿using System;

namespace TC
{
    public class IfElse : BTNode, IUpdate
    {
        public ValueInput<bool> condition;

        public FlowOutput<FlowNode> flowT;
        public FlowOutput<FlowNode> flowF;

        public override void Execute(Dispatcher chain)
        {
            base.Execute(chain);

            if (condition.Value)
            {
                chain.Call(flowT);
            }
            else
            {
                chain.Call(flowF);
            }
        }

        public void OnUpdate(float delta)
        {
            if (condition.Value)
            {
                chain.OnNodeChange(this);
            }
        }
    }
}